var _TEAM_ID_FOR_AJAX = 0; //默认全部
var _CURRENT_PAGENO = 1;  //默认当前页号
var selectArrayList = [];
//重置页面分页信息
function resetPageInfo(){
   _TEAM_ID_FOR_AJAX = 0; 
   _CURRENT_PAGENO = 1; 
}
//设置分页信息
function setPageInfo(teamId,currId){
   _TEAM_ID_FOR_AJAX = teamId; 
   _CURRENT_PAGENO = currId; 
   //alert("=====teamId======"+teamId+"====currId======"+currId)
}
//获得当前页码
function getCurrentPageNo(){
   return _CURRENT_PAGENO;
}
//获得当前组ID
function getTeamId(){
  return _TEAM_ID_FOR_AJAX;
}
//ajax 请求上一页
function getPrePageInfo(){
   var curId = getCurrentPageNo();
   var teamId = getTeamId();
   var parentTeamid = 	document.getElementById("parentTeamid").value;	 
   ajaxGetAttentionList(curId,teamId,-1,parentTeamid);
}
//ajax 请求下一页
function getNextPageInfo(){
   var curId = getCurrentPageNo();
   var teamId = getTeamId();
   var parentTeamid = 	document.getElementById("parentTeamid").value;	 
   ajaxGetAttentionList(curId,teamId,1,parentTeamid);
}
//根据页号ajax请求数据
function getPageInfo(curId){
    var teamId = getTeamId();
    var parentTeamid = 	document.getElementById("parentTeamid").value;	 
    ajaxGetAttentionList(curId,teamId,0,parentTeamid);
}
//ajax 请求 attenlist  inc 代表增量  值为 -1 ,0,1
function ajaxGetAttentionList(curId,teamid,inc,parentTeamid){ 
    if(inc!=0){
       if(inc>0){
          curId = curId+1;
       }else{
         if(curId>1){
          curId = curId-1;
         }
       }
    }
    var obj = document.getElementById("fanstype");
    var type = 0;
    if(obj!= null){
    	type = obj.value;
    }
	jQuery("#colItemDataBox").load("/app/my/docin/ajaxFollow?random="+Math.round(Math.random()*100)+"&currentPage="+curId+"&teamid="+teamid+"&pteamid="+parentTeamid + "&type=" + type,{limit:12},function(re,error){
	   if(error=='success'){
	    rememberAdd();
	    changeItems();
	    followControl();
	    changeFollowType();	
	    showElm(document.getElementById("followPop"));
	   }
	})
}
//添加所选关注者到分组
function submitSelectItems(pareId,teamid,currentPage){
     var ids = finishAddFollow();
     if(ids==0){
       alert("请选择关注人！");
       return;
     }
     window.location.href = "/app/my/docin/batchAddAttention?teamid="+teamid+"&ids="+ids+"&&currentPage="+currentPage;
}


//返回中英文混合字符串长度 中文长度为2
function fucCheckLength(strTemp) {
	var i, sum;
	sum = 0;
	for (i = 0; i < strTemp.length; i++) {
		if ((strTemp.charCodeAt(i) >= 0) && (strTemp.charCodeAt(i) <= 255)) {
			sum = sum + 1;
		} else {
			sum = sum + 2;
		}
	}
	return sum;
}
//关注
function overConcern(id1,id2){
	var id = id2.substr(7,id2.length);
	if(document.getElementById('fadd'+id).style.display == 'none'){
		document.getElementById(id1).style.display ='none';
		document.getElementById(id2).style.display ='';
	}else{
		document.getElementById(id1).style.display ='none';
		document.getElementById(id2).style.display ='none';
	}
	
}
function outConcern(id1,id2){
	var id = id1.substr(7,id1.length);
	if(document.getElementById('fadd'+id).style.display == 'none'){
		document.getElementById(id1).style.display ='none';
		document.getElementById(id2).style.display ='';
	}else{
		document.getElementById(id1).style.display ='none';
		document.getElementById(id2).style.display ='none';
	}
}
//取消关注
function cancelConcern(userid){
	document.getElementById('fcancel'+userid).style.display ='none';
	document.getElementById('fed'+userid).style.display ='none';
	document.getElementById('fadd'+userid).style.display ='';
	jQuery("#addCancelConcern").load("/app/my/docin/delfollow?random="+Math.round(Math.random()*100)+"&userid=" + userid);
}
//添加关注
function addConcern(userid){
	document.getElementById('fed'+userid).style.display ='';
	document.getElementById('fcancel'+userid).style.display ='none';
	document.getElementById('fadd'+userid).style.display ='none';
	jQuery("#addCancelConcern").load("/app/my/docin/addfollow?random="+Math.round(Math.random()*100)+"&userid=" + userid);
}
//取消关注fans页
function cancelConcernFans(userid){
	document.getElementById('fcancel'+userid).style.display ='none';
	document.getElementById('feach'+userid).style.display ='none';
	document.getElementById('fadd'+userid).style.display ='';
	jQuery("#addCancelConcern").load("/app/my/docin/delfollow?random="+Math.round(Math.random()*100)+"&userid=" + userid);
}
//添加关注fans页
function addConcernFans(userid){
	document.getElementById('feach'+userid).style.display ='';
	document.getElementById('fadd'+userid).style.display ='none';
	jQuery("#addCancelConcern").load("/app/my/docin/addfollow?random="+Math.round(Math.random()*100)+"&userid=" + userid);
}    
//选择分组
function select_team(id,teamid){
	jQuery("#followSkillsBoxJquery").load("/app/my/docin/concernuserteam?random="+Math.round(Math.random()*100)+"&concernuserid=" + id+"&teamid="+teamid);
	
}
//创建分组
function createUserTeam(){
	
	document.getElementById('addTeam').style.display ='block';
	document.getElementById('createUserTeam').style.display ='none';		
}
//
function saveInputTeam(){
	document.getElementById('createteam').onkeydown = function(e){
	 var e = e || event; 
	 var keyNum = e.which || e.keyCode; 
	 if(keyNum == 13){
	 	var teamName = document.getElementById('teamName').value;
		teamName = teamName.replace(/(^\s*)|(\s*$)/g,'');
		var teams = document.getElementsByName('teams') ;
		var index = 0;
		for(var i=0;i<teams.length;i++){
			if(teams[i].value == teamName || teamName=='名人' || teamName=='机构'|| teamName=='全部'){
				index++;
			}
		}
		if(index == 0 &&( teamName=='名人' || teamName=='机构'|| teamName=='全部')){
			index++;
		}
		if(teamName.length == 0){
			document.getElementById('createTeamTipsLi').style.display ='';
			document.getElementById('createTeamTips').innerHTML = "";
			document.getElementById('createTeamTips').innerHTML = "分组名不能为空";
			document.getElementById('createTeamTips').style.color="#ff0000";
			return false;
		}
		else if(index != 0){
			document.getElementById('createTeamTipsLi').style.display ='';
			document.getElementById('createTeamTips').innerHTML = "";
			document.getElementById('createTeamTips').innerHTML = "分组名已存在";
			document.getElementById('createTeamTips').style.color="#ff0000";
			return false;
		}
		else if(fucCheckLength(teamName) > 16){
			document.getElementById('createTeamTipsLi').style.display ='';
			document.getElementById('createTeamTips').innerHTML = "";
			document.getElementById('createTeamTips').innerHTML = "请不要超过16个字符";
			document.getElementById('createTeamTips').style.color="#ff0000";
			return false;
		}
		else{
			return true;
		}	
	  }
	};	
}
//保存创建的分组
function saveTeam(){
	var teamName = document.getElementById('teamName').value;
	teamName = teamName.replace(/(^\s*)|(\s*$)/g,'');
	var teams = document.getElementsByName('teams') ;
	var index = 0;
	for(var i=0;i<teams.length;i++){
		if(teams[i].value == teamName || teamName=='名人' || teamName=='机构'|| teamName=='全部'){
			index++;
		}
	}
	if(index == 0 &&( teamName=='名人' || teamName=='机构'|| teamName=='全部')){
		index++;
	}
	if(teamName.length == 0){
		document.getElementById('createTeamTipsLi').style.display ='';
		document.getElementById('createTeamTips').innerHTML = "";
		document.getElementById('createTeamTips').innerHTML = "分组名不能为空";
		document.getElementById('createTeamTips').style.color="#ff0000";
	}
	else if(index != 0){
		document.getElementById('createTeamTipsLi').style.display ='';
		document.getElementById('createTeamTips').innerHTML = "";
		document.getElementById('createTeamTips').innerHTML = "分组名已存在";
		document.getElementById('createTeamTips').style.color="#ff0000";
	}
	else if(fucCheckLength(teamName) > 16){
		document.getElementById('createTeamTipsLi').style.display ='';
		document.getElementById('createTeamTips').innerHTML = "";
		document.getElementById('createTeamTips').innerHTML = "请不要超过16个字符";
		document.getElementById('createTeamTips').style.color="#ff0000";
	}
	else{
		//closeAddFav('followSkillsBox');
		document.getElementById('createteam').submit();
	}
	
}
//取消创建分组
function cancelTeam(){
	document.getElementById('createUserTeam').style.display ='block';
	document.getElementById('addTeam').style.display ='none';
}
//显示创建分组div
function displayTeamDiv(){
	document.getElementById('teamDiv').style.display ='block';
}
//关闭创建分组div
function hiddenTeamDiv(){
	document.getElementById('teamDiv').style.display ='none';
}
//显示修改分组div
function modifyTeamName(){
	document.getElementById('modifyTeamDiv').style.display ='block';
}
//关闭修改分组div
function hiddenModiTeamDiv(){
	document.getElementById('modifyTeamDiv').style.display ='none';
}
//删除分组
function deleteTeam(id){
	var state = confirm('确认删除?');
		if(state){
			var url = "/app/my/docin/deleteteam?teamid="+id;
			window.location.href = url;
		}else{
			return;
		}
}
//保存
function saveTeamDiv(){
	var teamName = document.getElementById('teamDivName').value;
	teamName = teamName.replace(/(^\s*)|(\s*$)/g,'');
	var teams = document.getElementsByName('teamList') ;
	var index = 0;
	for(var i=0;i<teams.length;i++){
		if(teams[i].value == teamName || teamName=='名人' || teamName=='机构'|| teamName=='全部'){
			index++;
		}
	}
	if(index == 0 &&( teamName=='名人' || teamName=='机构'|| teamName=='全部')){
		index++;
	}
	if(teamName.length == 0){
		document.getElementById('teamDivTips').innerHTML = "";
		document.getElementById('teamDivTips').innerHTML = "分组名不能为空";
		document.getElementById('teamDivTips').style.color="#ff0000";
	}
	else if(index != 0){
		document.getElementById('teamDivTips').innerHTML = "";
		document.getElementById('teamDivTips').innerHTML = "分组名已存在";
		document.getElementById('teamDivTips').style.color="#ff0000";
	}
	else if(fucCheckLength(teamName) > 16){
		document.getElementById('teamDivTips').innerHTML = "";
		document.getElementById('teamDivTips').innerHTML = "请不要超过16个字符";
		document.getElementById('teamDivTips').style.color="#ff0000";
	}
	else{
		document.getElementById('saveTeamForm').submit();
	}
}
//更新
function saveModiTeamDiv(id,page){
	var teamName = document.getElementById('modifyTeamDivName').value;
	teamName = teamName.replace(/(^\s*)|(\s*$)/g,'');
	var teams = document.getElementsByName('teamList') ;
	var index = 0;
	for(var i=0;i<teams.length;i++){
		if(teams[i].value == teamName || teamName=='名人' || teamName=='机构'|| teamName=='全部'){
			index++;
		}
	}
	if(index == 0 &&( teamName=='名人' || teamName=='机构'|| teamName=='全部')){
			index++;
		}
	if(teamName.length == 0){
		document.getElementById('modifyTeamDivTips').innerHTML = "";
		document.getElementById('modifyTeamDivTips').innerHTML = "分组名不能为空";
		document.getElementById('modifyTeamDivTips').style.color="#ff0000";
	}
	else if(index != 0){
		document.getElementById('modifyTeamDivTips').innerHTML = "";
		document.getElementById('modifyTeamDivTips').innerHTML = "分组名已存在";
		document.getElementById('modifyTeamDivTips').style.color="#ff0000";
	}
	else if(fucCheckLength(teamName) > 16){
		document.getElementById('modifyTeamDivTips').innerHTML = "";
		document.getElementById('modifyTeamDivTips').innerHTML = "请不要超过16个字符";
		document.getElementById('modifyTeamDivTips').style.color="#ff0000";
	}
	else{
		var url = "/app/my/docin/modifyteam?teamid="+id+"&currentPage="+page+"&teamName="+teamName;
		window.location.href = url;
	}
}
//页面
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == "string") {
			element = document.getElementById(element);
		}
		if (arguments.length == 1) {
			return element;
		}
		elements.push(element);
	}
	return elements;
}
document.getElementsByClassName = function (eleClassName) {
	var getEleClass = [];//定义一个数组 
	var myclass = new RegExp("\\b" + eleClassName + "\\b");//创建一个正则表达式对像 
	var elem = this.getElementsByTagName("*");//获取文档里所有的元素 
	for (var h = 0; h < elem.length; h++) {
		var classes = elem[h].className;//获取class对像 
		if (myclass.test(classes)) {
			getEleClass.push(elem[h]);
		}//正则比较，取到想要的CLASS对像 
	}
	return getEleClass;//返回数组 
};

function hasClass(ele, cls) {
	if(ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"))){
		return true;
	}else return false;
}

function shareFans(){
	var obj = document.getElementById("endShare_Tip");
		if(obj != null){
			obj.style.display="none";
		}
}
function addClass(ele, cls) {
	if (!this.hasClass(ele, cls)) {
		ele.className += " " + cls;
	}
  }
 function   getXYWH(o){
	var   nLt=0;
	var   nTp=0;
	  var   offsetParent   =   o;
	  while   (offsetParent!=null   &&   offsetParent!=document.body)   {
	  nLt+=offsetParent.offsetLeft;
	  nTp+=offsetParent.offsetTop;
	  offsetParent=offsetParent.offsetParent;
	  }
	  this.showL=nLt;
	  this.showT=nTp;
	  this.showW=o.offsetWidth;
	  this.showH=o.offsetHeight;
}
/*阻止事件冒泡*/
 function stopBubble(e) {
        if ( e && e.stopPropagation )
            e.stopPropagation();
        else
            window.event.cancelBubble = true;
    }

function closeAddFav(obj) {
	var d = document,
	o = d.getElementById(obj);
	if (!o) {
		return false;
	}
	
	//获得当前选中分组,异步提交修改
	var teamIds =  document.getElementsByName("selectTeamId");
	var selectTeamId="";
	var concernUserId = document.getElementById("concernUserId").value;
    for(i=0;i<teamIds.length;i++){
        if(teamIds[i].checked==true){
        	if(i==0){
        		selectTeamId = teamIds[i].value;
        	}else{
        		selectTeamId = selectTeamId+','+teamIds[i].value;
        	}
        }
    }
    selectTeam(concernUserId);
    jQuery("#addCancelConcern").load("/app/my/docin/saveperson2teams?random="+Math.round(Math.random()*100)+"&concernUserId="+concernUserId+"&selectTeamId=" + selectTeamId);
    o.style.cssText = ";display:none";
}
//复制到剪切板
function copyurl(){
	url=document.getElementById("link_url").value;
	document.getElementById("link_url").value=url;
	
	document.getElementById("link_url").focus();
	document.getElementById("link_url").select();
	
	copyToClipboard(url);
}
 
//拷贝到剪切板
function copyToClipboard(txt) { 
	if(window.clipboardData) { 
		window.clipboardData.clearData(); 
		window.clipboardData.setData("Text",txt); 		
	} else if(navigator.userAgent.indexOf("Opera")!= -1) { 
		window.location = txt; 
	} else if (window.netscape) { 
		try { 
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
		} catch (e) { 
			alert("您的firefox安全限制限制您进行剪贴板操作，请打开'about:config'将signed.applets.codebase_principal_support'设置为true'之后重试,具体可以参考http://www.jb51.net/article/16705.htm"); 
			return false; 
		} 
		var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard); 
		if (!clip) 
			return; 
		var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable); 
		if (!trans) 
			return; 
		trans.addDataFlavor('text/unicode'); 
		var str = new Object(); 
		var len = new Object(); 
		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); 
		var copytext = txt; 
		str.data = copytext; 
		trans.setTransferData("text/unicode",str,copytext.length*2); 
		var clipid = Components.interfaces.nsIClipboard; 
		if (!clip) 
			return false; 
		clip.setData(trans,null,clipid.kGlobalClipboard); 
	} 
	alert("复制成功！"); 
} 
//msn登陆
var oncli = "0";
function msnLogin(){
	if(oncli == "1"){
		return;
	}
	var msn_e=document.getElementById("msn_email").value;
	var msn_p=document.getElementById("msn_pwd").value;
	if(msn_e==""){
		alert("请填写邮箱地址");
		return ;
	}
	if(msn_p==""){
		alert("请填写密码");
		return;
	}

	document.getElementById("msn_login_sp").innerHTML="正在查找请稍候...";
	document.getElementById("imgdong").style.display = "block";
	oncli = "1";
	jQuery("#msn_user").load("/app/my/docin/getemails4msn?random="+Math.round(Math.random()*100)+"&email="+msn_e+"&pwd=" + msn_p);
}
function msn_back(data){
	oncli = "0";
	//alert(data);
	if (data ==null || data.length == 0) {
       alert("登录失败或msn中的联系人没有豆丁账户!");
	   document.getElementById("msn_login_sp").innerHTML="<input type='button' title='查找并邀请好友' value='查找并邀请好友' onclick='javascript:msnLogin();' class='btn-tips'>";
	   document.getElementById("msn_login_sp").disabled = false;
	   document.getElementById("imgdong").style.display = "none";
	   
   }else{
   		document.getElementById("msn_login").style.display="none";
		document.getElementById("msn_user").style.display="";
    	addmsnuser(data);
   }
}


//添加msn账户
function addmsnuser(data){	
	var t="";
	
	if(is_register=="group"){
		for(var i=0;i<data.length;i++){     		     
			t += "<tr>";
			t += "<td>";
			t += "<input type='checkbox' id='msn_cb_id' name='msn_cb_email' value='"+data[i].loginEmail+"'  checked='checked' />";
			t += "</td>";
			t += "<td><a href='/u-"+data[i].userId+".html' target='_blank'><img src='"+data[i].portraitPath+"'/></a><p><a  href='/u-"+data[i].userId+".html' target='_blank'>"+data[i].nikeName+"</a></p><p><span>"+data[i].sex+"</span><span>"+data[i].city+"</span></p></td>";
			t += "</tr>";
	    }
	}else{
		for(var i=0;i<data.length;i++){     		     
			if(data[i].userId>0){
		   		t+="<tr><td><input type='checkbox' id='msn_cb_id' name='msn_cb' value='"+data[i].userId+"'  checked='checked' /></td><td><a href='/u-"+data[i].userId+".html' target='_blank'><img src='"+data[i].portraitPath+"'/></a><p><a  href='/u-"+data[i].userId+".html' target='_blank'>"+data[i].nikeName+"</a></p><p><span>"+data[i].sex+"</span><span>"+data[i].city+"</span></p></td></tr>";
			}else{
				t+="<tr><td><input type='checkbox' id='msn_cb_id' name='msn_cb_email' value='"+data[i].loginEmail+"'  checked='checked' /></td><td><img src='"+data[i].portraitPath+"'/><p>"+data[i].nikeName+"&nbsp;<span>"+data[i].loginEmail+"</span></p><p><span>"+data[i].sex+"</span><span>"+data[i].city+"</span></p></td></tr>";
			}
				
	    }
    }
	h="<table  id='msn_list'><colgroup><col class='colone'/><col class='coltwo'/></colgroup><tr><th><input type='checkbox' onclick='msn_select_all(\"chkall\")' id='chkall' name='chkall'  checked='checked' /></th><th><span style='margin: 0pt 8px 0pt 0pt; float: right;'' onclick='showMsnDivListS();'><a href='javascript:void(0);'>返回</a></span>全选</th></tr>"
	h=h+t+"</table>";
	document.getElementById("msn_div_list").innerHTML= h;		
}

//选择所有用户msn
function msn_select_all(name){
	
	 var chkall= document.getElementById(name);
	 var chkother= document.getElementsByTagName("input");
	 for (var i=0;i<chkother.length;i++)
	 {
	  if( chkother[i].type=='checkbox')
	       {
	   if(chkall.checked==true)
	    {
	       chkother[i].checked=chkall.checked;
	    }else
	    {
	     chkother[i].checked="";
	    }
	  }
	 }
}


//添加好友msn
function addFriendsByCheckBox(){
	
	var friendsId=getFriendsIdByCheckBox();
	var friendsEmail=getFriendsEmailByCheckBox();
	if(friendsId=='' && friendsEmail==''){
		alert("请先选择好友");
	}else{
		//alert(friendsId);
		showMsnSendMsg();
	}
	
}
//重置验证码
function refCode(img_id){
	var checkImg=document.getElementById(img_id);
	//alert(checkImg);
	if(checkImg!=null){
		checkImg.style.display="";
		checkImg.src="/servlet/getimg?"+getTime();
	}
}
function getTime(){
	var d, s = "";
	var c = "";
	d = new Date();
	s += d.getYear()+c;
	s += (d.getMonth() + 1) + c;
	s += d.getDate() + c;
	s += d.getHours() + c;
	s += d.getMinutes() + c;
	s += d.getSeconds() + c;
	s += d.getMilliseconds();
	return s;
}
var is_register = "";
//发送email邀请好友
function sendEmail(){
	name=document.getElementById("sendEmailUserName").value; 
	randCode1=document.getElementById("checkout_email").value;
	emails=document.getElementById("emaillist").value;
	if(emails==""){
		alert("请填写邮件地址");
		return ;
	}
	if(randCode1==""){
		alert("请填写校验码");
		return ;
	}
	
	emails = trim(emails);
	arr = emails.split(/[ |,|;|，|；]/);
	len = 0;	
	for(i=0;i<arr.length;i++){
		len++;		
		if(checkEmail(arr[i])==false){
			alert("第"+len+"个邮件地址输入错误，请重新输入!");
			return;
		}
	}
	if(len>10){
		alert("每次最多只能发送10封邮件");
		flag = false;
		return;
	}
	
	
	var url = "/app/my/docin/invitefriendsemail?random="+Math.round(Math.random()*100)+"&emails=" + emails + "&randcode=" + randCode1+"&name="+name;
	jQuery.post(url,null,function(data){
			sendEmail_back(data);
		}
	);
	
}
function sendEmail_back(data){
	//0:未登录 -1:填写内容不全 1:发送成功
	if(data != null){
		if(data == 0){
			 alert("你还未登录,登录后重新操作");
			 window.location.href="/app/my/docin/invitefriends";
		}else if(data == -1){
			alert("邮件地址没有填写");
		}else if(data == -2){
			alert("校验码出错");
		}else if(data == 1){
			if(is_register!="group"){
				alert("成功发送邀请邮件！对方应邀加入时，将自动加为你的好友");
				window.location.href="/app/my/docin/follow";
			}else{
				alert("成功发送邀请邮件！对方应邀加入时，将自动加入你的小组");
			}
		}
	}
}

  function boxShare(obj,elem){
	var nmove,mmove,
		d = document,
		o = document.getElementById(obj),
		s = document.getElementById(elem);
	if(!o){ return false};
	if(!s){ return false};
	
	s.onmouseover=function(){
		clearTimeout(nmove);
		s.style.display="block";
	}
	o.onmouseover=function(){
		clearTimeout(nmove);
		mmove=setTimeout(function(){s.style.display="block";},100);
	}
	o.onmouseout=function(){
		clearTimeout(mmove);
		nmove=setTimeout(function(){s.style.display="none";},500);
	}
	s.onmouseout=function(){
		nmove=setTimeout(function(){s.style.display="none";},500);
	}
	/*s.onmousedown=function(e){
		stopBubble(e);
		return false;
	}*/
}
function addFav(obj,elem){
 	var d = document,
	o = d.getElementById(obj);
	if (!o) {
		return false;
	}
	var sObj = new getXYWH(elem);
	if(o.getElementsByTagName("div")[0] != null &&o.getElementsByTagName("div")[0] != "undefined"){
	o.getElementsByTagName("div")[0].innerHTML = elem.innerHTML;
	o.style.cssText = ";top:" + (sObj.showT - 2) + "px;" + "left:" + (sObj.showL - 8) + "px;display:block";
	}
		
}
 function hideElm(elm){
		elm.style.display = "none";	
		setPageInfo(0,1);//重置页面分页信息		
	}
function showElm(elm){
        (0,1);//重置页面分页信息
		elm.style.display = "block";				
	}
function delPer(){
	//var per = document.getElementsByClassName("btn_del");
	
	var per = document.getElementById("friend-lists").childNodes;
	for(var i=0;i<per.length;i++){
		per[i].onclick=function(e){			
			var did = this.id.replace("af","pl");
			stopBubble(e);				
			if($(did)){
				removeClass($(did),"cur");	
			}
				this.parentNode.removeChild(this);		
			}
		}		
}
function addFlo(){
	var addper = document.getElementsByClassName("perlist");
	for(var j=0;j<addper.length;j++){		
		addper[j].onclick=function(){
			var str = this.childNodes[1].innerHTML.replace(/<.+?>/gim,'');	
			var friend = $("friend-lists");			
			var pid = this.getAttribute("id");
			pid = pid.replace("pl","af");			
			if(!hasClass(this,"cur")){
			addClass(this,"cur");			
			var li = document.createElement("li");
			li.id = pid;
			li.innerHTML = str + '<span class="btn_del" title="删除">x</span>';
			friend.appendChild(li);
			delPer();
			}else{
			removeClass(this,"cur");			 
			friend.removeChild($(pid));			
				}
			}
		}
		var obj = document.getElementById("endShare_Tip");
		if(obj != null){
			obj.style.display="none";
		}
	}
function finishAddFollow(){
		
			var c= $("friend-lists").children;	
			if(c.length>1){
				var followId = [];
				for(var k=1;k<c.length;k++){
						var id = c[k].id;
						id = id.substring(id.indexOf("_")+1);						
						followId.push(id);
					}
				return followId.join(",");				
				}
		return 0;
	}
function followControl(){
		var per = document.getElementById("friend-lists");
		if(per != null ){
			delPer();
		}
		addFlo();
		hidePerBox();
	}
function hidePerBox(){	
	try{	
	var closebt = document.getElementById("closeItemBox");
	var box = document.getElementById("followPop");
	closebt.onclick = function(){
		hideElm(box);
		var btnup = $("choose-friend");
		removeClass(btnup,"colItem-btnUp");
		}
	var div = document.getElementById("friend-lists");
	 	div.onclick= function(){
	 		if(!hasClass(this,"visiable")){
		 		addClass(this,"visiable");	 
		 		addClass(document.getElementById("choose-friend"),"colItem-btnUp");		
		 		var parentTeamid = 	document.getElementById("parentTeamid").value;	 	
		 		ajaxGetAttentionList(1,0,0,parentTeamid);		 	
		 		//showElm(box);
		 		}
	 		else{
	 			removeClass(this,"visiable");
	 			removeClass(document.getElementById("choose-friend"),"colItem-btnUp");
	 			hideElm(box);
	 		}
	 	}
	var btnup = document.getElementById("choose-friend");
	
	btnup.onclick = function(){
	if(!hasClass(btnup,"colItem-btnUp")){
		var parentTeamid = 	document.getElementById("parentTeamid").value;
	    ajaxGetAttentionList(1,0,0,parentTeamid);//异步请求数据
		//showElm(box);
		addClass(btnup,"colItem-btnUp");		
		}else{
		hideElm(box);
		removeClass(btnup,"colItem-btnUp");	
		}		
		}
		}catch(e){
			return;
		}
	}
function changeItems(){
	var more = $("friend-type");
	var moretypebox = $("colItemSearSkillsBox");
	moretypebox.onmouseover = function (){
		this.style.display = "block";
		};
	moretypebox.onmouseout = function (){
		this.style.display = "none";
		};
	var moreType = document.getElementById("moreFollowType");
	if(moreType){
		moreType.onclick = function(){
		addClass(this,"moreSelect");
		$("colItemSearSkillsBox").style.display="block";		
		var moreitem = $("more-item").childNodes;
		for(var i=0 ;i<moreitem.length; i++){
			moreitem[i].onclick = function(){
				var l,ns,os;
				ns = this.childNodes[0].innerHTML;			
				if(!window.ActiveXObject){
				l = $("friend-type").children[$("friend-type").children.length -2];					
				os = l.firstChild.innerHTML;
				}else{
				l = $("friend-type").lastChild.previousSibling;
				os = l.innerText;
					}
				l.setAttribute("title",ns);
				l.innerHTML = "<span>" + ns + "</span>";	
				this.childNodes[0].innerHTML = os;
				this.childNodes[0].setAttribute("title",os);
				}
			}
			}
		}
	}
function changeFollowType(){
	var typeList = $("friend-type").childNodes;
	if(window.ActiveObject){
		var l = typeList.length - 1;
		}else{
		var l = typeList.length - 2;	
			}
	for(var i=0;i<l;i++){
		typeList[i].onclick = function(){
			if(hasClass(this,"cur")){								
				addClass(this,"cur");				
				}else{
				for(var k=0;k<typeList.length;k++){
					removeClass(typeList[k],"cur");
					}
				addClass(this,"cur");					
					}			
		}
	}
	}
	Array.prototype.contains = function (element) { 
           for (var i = 0; i < this.length; i++) { 
              if (this[i] == element) { 
                  return true; 
              } 
           } 
          return false; 
     }
    function rememberAdd(){
		var c= $("friend-lists").children;			
		if(c.length>1){
			var followAdd = [];
			var changeFollow = [];
			for(var k=1;k<c.length;k++){
					followAdd.push(c[k].id.replace("af","pl"));
				}
			var selectFollow = $("person-list").children;
			for(var j=0;j<selectFollow.length;j++){
					if(followAdd.contains(selectFollow[j].id)){
						addClass(selectFollow[j],"cur");
						}
				}
			}
	
	}
  window.onload = function(){
	followControl();	
	}
//选择文件夹
function selectTeam(id){
	var teamIds =  document.getElementsByName("selectTeamId");
	var teamName = '';
	var index = 0;
    for(i=0;i<teamIds.length;i++){
        if(teamIds[i].checked==true){
        	index++;
        	if(i ==0 && 'tName'+teamIds[i].value != null){
        		teamName = document.getElementById('tName'+teamIds[i].value).value;
        	}
        	else{
        		teamName = teamName+','+document.getElementById('tName'+teamIds[i].value).value;
        	}
        }
    }
    if(teamName == ''){
    	teamName ='全部';
    }
    else{
    	if(index>=3){
    		if(teamName.length>1 && teamName.substring(0,1) == ','){
    			teamName = countCharacters(teamName.substring(1,teamName.length),9)+",..";
    		}else{
    			teamName = countCharacters(teamName.substring(0,teamName.length),9)+",..";
    		}
    	}else{
    		if(teamName.length>1 && teamName.substring(0,1) == ','){
    			teamName = countCharacters(teamName.substring(1,teamName.length),12);
    		}else{
    			teamName = countCharacters(teamName.substring(0,teamName.length),12);
    		}
    	}
    	
    }
	document.getElementById('tItem'+id).innerHTML=teamName;
}
//截取字符串
function countCharacters(str,size){ 
     var totalCount = 0;  
     var newStr = ""; 
     for (var i=0; i<str.length; i++) {  
         var c = str.charCodeAt(i);  
         if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) {  
             totalCount++;  
         }else {     
             totalCount+=2;  
         }  
         if(totalCount<size){ 
             newStr = str.substring(0,i+1); 
         }else{ 
             return newStr+"..."; 
         } 
     } 
     return newStr; 
}
//限制输入字数
function gbcount(message,total,remain)
{
	document.getElementById('saveTeamForm').onkeydown = function(e){
	 var e = e || event; 
	 var keyNum = e.which || e.keyCode; 
	 if(keyNum==13){
	 	var teamName = document.getElementById('teamDivName').value;
		teamName = teamName.replace(/(^\s*)|(\s*$)/g,'');
		var teams = document.getElementsByName('teamList') ;
		var index = 0;
		for(var i=0;i<teams.length;i++){
			if(teams[i].value == teamName || teamName=='名人' || teamName=='机构'|| teamName=='全部'){
				index++;
			}
		}
		if(index == 0 &&( teamName=='名人' || teamName=='机构'|| teamName=='全部')){
			index++;
		}
		if(teamName.length == 0){
			document.getElementById('teamDivTips').innerHTML = "";
			document.getElementById('teamDivTips').innerHTML = "分组名不能为空";
			document.getElementById('teamDivTips').style.color="#ff0000";
			return false;
		}
		else if(index != 0){
			document.getElementById('teamDivTips').innerHTML = "";
			document.getElementById('teamDivTips').innerHTML = "分组名已存在";
			document.getElementById('teamDivTips').style.color="#ff0000";
			return false;
		}
		else if(fucCheckLength(teamName) > 16){
			document.getElementById('teamDivTips').innerHTML = "";
			document.getElementById('teamDivTips').innerHTML = "请不要超过16个字符";
			document.getElementById('teamDivTips').style.color="#ff0000";
			return false;
		}
		else{
			return true;
		}
	 }else{
	 	var max;
		 max = total;
		 var insertChar = fucCheckLength(document.getElementById(message).value);
		 if (insertChar > max) {
		  document.getElementById(message).value = document.getElementById(message).value.substring(0,max);
		  document.getElementById(remain).innerHTML = " ";
		  document.getElementById(remain).innerHTML = "你还可以输入0个字";
		 }
		 else {
		   document.getElementById(remain).innerHTML = " ";
		   document.getElementById(remain).innerHTML = "你还可以输入"+(max - insertChar )+"个字";
		 }
	 }
	};
}
//更多创建分组
function createMoreTeam(){	
	document.getElementById('addMoreTeam').style.display ='block';
	document.getElementById('createMoreTeam').style.display ='none';		
}
//更多保存创建的分组
function saveMoreTeam(){
	var teamName = document.getElementById('teamMoreName').value;
	teamName = teamName.replace(/(^\s*)|(\s*$)/g,'');
	var teams = document.getElementsByName('teamList') ;
	var index = 0;
	for(var i=0;i<teams.length;i++){
		if(teams[i].value == teamName || teamName=='名人' || teamName=='机构'|| teamName=='全部'){
			index++;
		}
	}
	if(index == 0 &&( teamName=='名人' || teamName=='机构'|| teamName=='全部')){
			index++;
		}
	if(teamName.length == 0){
		document.getElementById('createMoreTeamTips').style.display ='block';
		document.getElementById('createMoreTeamTips').innerHTML = "";
		document.getElementById('createMoreTeamTips').innerHTML = "分组名不能为空";
		document.getElementById('createMoreTeamTips').style.color="#ff0000";
	}
	else if(index != 0){
		document.getElementById('createMoreTeamTips').style.display ='block';
		document.getElementById('createMoreTeamTips').innerHTML = "";
		document.getElementById('createMoreTeamTips').innerHTML = "分组名已存在";
		document.getElementById('createMoreTeamTips').style.color="#ff0000";
	}
	else if(fucCheckLength(teamName) > 16){
		document.getElementById('createMoreTeamTips').style.display ='block';
		document.getElementById('createMoreTeamTips').innerHTML = "";
		document.getElementById('createMoreTeamTips').innerHTML = "不能多于16个字";
		document.getElementById('createMoreTeamTips').style.color="#ff0000";
	}
	else{
		window.location.href="/app/my/docin/saveteam?teamDivName="+teamName;
	}
	
}
//更多取消创建分组
function cancelMoreTeam(){
	document.getElementById('createMoreTeam').style.display ='block';
	document.getElementById('addMoreTeam').style.display ='none';	
}
//全选反选
function selectAll(){
	obj = document.getElementsByName('msnUser');
	for(i=0;i<obj.length;i++){
		obj[i].checked=(obj[i].checked)? false :true;
		var id = obj[i].value;
	}
}
//取消msn邀请
function cancelMsnEmail(){
	oncli = "0";
	document.getElementById("msn_login_sp").style.display="block";
	document.getElementById("msn_login_sp").disabled = false;
	document.getElementById("msn_login_sp").innerHTML="<input type='button' title='查找并邀请好友' value='查找并邀请好友' onclick='javascript:msnLogin();' class='btn-tips'>";
	document.getElementById("msn_user").style.display="none";
}
//发送email邀请好友
function sendMsnEmail(){
	
	obj = document.getElementsByName('msnUser');
	var emails;
	for(i=0;i<obj.length;i++){
		if(obj[i].checked==true){
			emails = obj[i].value+',';
		}
	}
	if(obj.length>100){
		alert('每次发送不能超过100人');
	}else{
		var url = "/app/my/docin/invitefriendsemail?random="+Math.round(Math.random()*100)+"&emails=" + emails + "&randcode=5732z&name=";
		jQuery.post(url,null,function(data){
			sendEmail_back(data);
		});
	}
}